import scrapy


class ProducerSpider(scrapy.Spider):
    name = "producer"
    async def start(self):
        url = 'http://quotes.toscrape.com/'
        yield scrapy.Request(url)

    def parse(self, response):
        items = response.xpath('//div[@class="quote"]')
        for item in items:
            author = item.xpath('.//small[@class="author"]/text()').get().strip()
            text = item.xpath('.//span[@class="text"]/text()').get().strip()[1:-1]
            tags = item.xpath('.//a[@class="tag"]/text()').getall()
            yield {
                'author': author,
                'text': text,
                'tags': tags,
            }
        next_url = response.xpath('//li[@class="next"]/a/@href').get()
        if next_url:
            yield response.follow(next_url)
